package mysql

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	UserId    int    `gorm:"type:int(11);not null;index:ip_idx"`
	Total     int    `gorm:"type:int(11);not null;"`
	NumberInt string `gorm:"type:varchar(50);not null;"`
	Status    int    `gorm:"type:int(11);not null;"`
	Title     string `gorm:"type:varchar(50);not null;"`
}

type OrderGood struct {
	gorm.Model
	OrderId int    `gorm:"type:int(11);not null;index:ip_idx"`
	Title   string `gorm:"type:varchar(40);not null;"`
	Price   int    `gorm:"type:int(11);not null;"`
	Stock   int    `gorm:"type:int(11);not null;"`
}

func (O *Order) Order() error {
	return DB.Debug().Model(&O).Create(&O).Error
}

func (OG *OrderGood) OrderGood() error {
	return DB.Debug().Model(&OG).Create(&OG).Error
}
